package com.powervision.base.util

import android.util.Log
import com.powervision.base.BuildConfig
import com.powervision.base.util.LogUtils
import java.lang.UnsupportedOperationException

/**
 * log日志打印工具类
 */
class LogUtils private constructor() {
    companion object {
        private val TAG = LogUtils::class.java.name
        private val IS_DEBUG = BuildConfig.DEBUG

        /**
         * 以下是自定义TAG打印
         */
        fun v(tag: String, message: String) {
            if (IS_DEBUG) {
                Log.v(tag, message)
            }
        }

        fun d(tag: String, message: String) {
            if (IS_DEBUG) {
                Log.d(tag, message)
            }
        }

        fun i(tag: String, message: String) {
            if (IS_DEBUG) {
                Log.i(tag, message)
            }
        }

        fun w(tag: String, message: String) {
            if (IS_DEBUG) {
                Log.w(tag, message)
            }
        }

        fun e(tag: String, message: String) {
            if (IS_DEBUG) {
                Log.e(tag, message)
            }
        }

        /**
         * 以下是自定义TAG打印,并且带错误信息
         */
        fun v(tag: String, message: String, throwable: Throwable?) {
            if (IS_DEBUG) {
                Log.v(tag, message, throwable)
            }
        }

        fun d(tag: String, message: String, throwable: Throwable?) {
            if (IS_DEBUG) {
                Log.d(tag, message, throwable)
            }
        }

        fun i(tag: String, message: String, throwable: Throwable?) {
            if (IS_DEBUG) {
                Log.i(tag, message, throwable)
            }
        }

        fun w(tag: String, message: String, throwable: Throwable?) {
            if (IS_DEBUG) {
                Log.w(tag, message, throwable)
            }
        }

        fun e(tag: String, message: String, throwable: Throwable?) {
            if (IS_DEBUG) {
                Log.e(tag, message, throwable)
            }
        }

        /**
         * 以下是默认TAG打印
         */
        fun v(message: String) {
            if (IS_DEBUG) {
                Log.v(TAG, message)
            }
        }

        fun d(message: String) {
            if (IS_DEBUG) {
                Log.d(TAG, message)
            }
        }

        fun i(message: String) {
            if (IS_DEBUG) {
                Log.i(TAG, message)
            }
        }

        fun w(message: String) {
            if (IS_DEBUG) {
                Log.w(TAG, message)
            }
        }

        fun e(message: String) {
            if (IS_DEBUG) {
                Log.e(TAG, message)
            }
        }
    }

    init {
        throw UnsupportedOperationException("cannot be instantiated")
    }
}